package com.p2p.front.dal.dao;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.p2p.base.dao.BaseMapper;
import com.p2p.base.page.PageVo;
import com.p2p.front.dal.model.IdCardInfo;
import com.p2p.front.dal.model.LoanInfo;

public interface IdCardDao extends BaseMapper {
	
	@Insert("insert into p2p_idcard_info(uid,id_card,real_name,status) values(#{uid},#{idCard},#{realName},#{status})")
	void save(IdCardInfo idCard);
	
	@Select("select id,uid, id_card,real_name,status from p2p_idcard_info order by id desc")
	@ResultMap(value="IdCardInfoResultMap")
	List<IdCardInfo> listPageBackend(PageVo form);

	@Select("select id,uid, id_card,real_name,status from p2p_idcard_info where uid =#{uid}")
	@ResultMap(value="IdCardInfoResultMap")
	IdCardInfo getByUid(String uid);
	
	@Select("select id,uid, id_card,real_name,status from p2p_idcard_info where uid =#{uid}  order by id desc limit 0,1")
	@ResultMap(value="IdCardInfoResultMap")
	IdCardInfo getAuthing(String uid);
	
	@Select("select * from p2p_idcard_info where id_card=#{id_card} and status = 1")
	Map<String,Object> findAuthed(String id_card);

	@Update("update p2p_idcard_info set status = #{status} where id=#{id} and uid = #{uid}")
	void updateIdCardStatus(IdCardInfo idCard);

}
